Cameras can be used to photograph, scan different types of barcodes or even barcodes on bills. It should be noted that the camera is a piece of hardware that is placed inside phones or other devices, and also to use it, you need a software that is installed and defined inside the phone system so that it can be hard. Used the software for the required things. In this part of the tutorial, we want to talk about how to set up and use the existing camera software .
The methods used to use the camera in Android systems are as follows:
1- Using an interface program:
Using the interface program, you can use the camera software and record your photo, then transfer it to another application to get the required output.
2- Using API:
In this method, they directly use the camera software and the API that exists inside the system directly and without any interface.Sometimes we use the default camera directly in the system to take photos or record video, which is the second method of setting up the camera, and in this method, in fact, the APIs are used directly and without any interface. we do. In this method, photography and video recording are done in the same camera environment and photos and videos are stored in the same environment and there is no need to transfer them to another application and program .In this part of the tutorial, we want to do the first method, and in fact, we have nothing to do with the second method, which takes photos and record videos in the same environment. In the continuation of this tutorial, I will do the second method as well.1- We create a new project in Android Studio and choose its name as desired. The name of the project we have chosen in this tutorial is Camera.2- The type of activity that we need in this project is Blank Activity. It is better to choose an activity of this type.3- We need to create the user interface and in this user interface we need a Button and ImageView.4- Add a uses-feature tag to the project as follows:
<uses-feature android: name = "android. hardware. camera" android: required = "true" />
It is worth mentioning that by entering the above code in the project, I also mention to all virtual stores such as Google Play that android. hardware. camera must exist, and the existence of this is essential for the performance of the application. If there are devices that do not support this feature, they will not be displayed in the application list.
The code that should be in the AndroidManifest.xml section is as follows:
<? xml version = "1.0" encoding = "utf-8"?>
<manifest xmlns: android = "http://schemas.android.com/apk/res/android"
package = "com.dotnek. camera">
<uses-feature android: name = "android. hardware. camera" android: required = "true" />
<application
android: allowBackup = "true"
android: icon = "@ mipmap / ic_launcher"
android: label = "@ string / app_name"
android: roundIcon = "@ mipmap / ic_launcher_round"
android: supportsRtl = "true"
android: theme = "@ style / AppTheme">
<activity android: name = ". MainActivity">
<intent-filter>
<action android: name = "android. intent. action. MAIN" />
<category android: name = "android. intent. category. LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Note:
In this section we do not need to get permission to use the camera, because we use a side program to do so. It is necessary to get a license from the camera when we want to use the main and default system camera directly and using the API, in other words, in the continuation of this tutorial, which we will do in the second way, we must have a license.5- We edit the activity layout as follows:
Read more on:https://www.dotnek.com/Blog/Apps/how-to-work-with-cameras-on-android-devices-i
link:https://dotnek.mystrikingly.com/
Related link:DOTNEK BLOG
:: برچسبها:
dotnek ,
seo ,
site ,
:: بازدید از این مطلب : 89
|
امتیاز مطلب : 0
|
تعداد امتیازدهندگان : 0
|
مجموع امتیاز : 0